import Vue from 'vue'
import App from './App'
import router from './router'
import './plugins/element'
import './assets/css/global.css' //全局样式
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/fonts/iconfont.css'  // 引入本地阿里图标-icont
import TreeTable from 'vue-table-with-tree-grid'

// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

// require styles
// require styles 导入富文本编辑器样式css
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";

// 自动退出文件路径
import auto_loginout from '../src/util/auto_loginout'

Vue.use(auto_loginout)

Vue.use(VueQuillEditor); //将富文本编辑器组件全局注册

import axios from "axios";
// 导入loading进度条依赖包和css样式表
import NProgress from "nprogress"
import 'nprogress/nprogress.css'
import {config} from "shelljs";


Vue.prototype.$http = axios
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
// axios拦在器
// **request拦截器中启用nprogress进度条NProgress.start()---请求拦截器，刚发送请求

axios.interceptors.request.use(config => {
  console.log(config)
  NProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

// 在response拦截器中停用NProgress进度条NProgress.done()---相应拦截器，请求完毕
axios.interceptors.response.use(config => {
  NProgress.done()
  return config

})

Vue.config.productionTip = false

Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // return `yyyy-mm-dd hh:mm:ss`   //上下写法一样
  return `${y}-${m}-${d} ${hh}:${mm}:${ss} `

})

Vue.component('tree-table', TreeTable)

/* eslint-disable no-new */
Vue.use(ElementUI)
new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
})
